package StudyCode.summary.myfile;

import java.nio.file.Path;
import java.nio.file.Paths;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class GetPathRootParentAndElement {
	public static void main(String[] args) {

		Path path = Paths.get("E:", "Copy/1/2", "test.txt");
		System.out.println("path 代表的文件或文件夹名称: " + path.getFileName());
		System.out.println("根目录: " + path.getRoot());
		System.out.println("父目录: " + path.getParent());
		System.out.println("路径节点个数: " + path.getNameCount());
		for (int i = 0; i < path.getNameCount(); i++) {
			System.out.println("节点 " + i + " 是: " + path.getName(i));
		}
		System.out.println("截取 (0,3): " + path.subpath(0, 3));
	}
}
